x<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
	<title> 继承的练习</title>
</head>
<body>
<h1>继承的练习</h1>
<?php 
/*集成允许建立一个新的派生类，从一个先前定义的类中集成数据和函数，而且可以重新定义或加进来的数据和函数。
子类对父类功能的拓展。
子类可以重载父类的方法
在PHP中只能用单继承
关键字：extends

*/

class Person 
{

	protected $name;
	protected $age;
	protected $sex;
	function __construct($name,$age=20,$sex="男"){
		$this->name=$name;
		$this->age=$age;
		$this->sex=$sex;

	}
	
	function say(){
		echo "我的名字是".$this->name."我的年龄是"
		.$this->age."我的性别是".$this->sex."<br>";

					}


	
}

class Student extends Person  {
	var $school;
	function study(){
			echo $this->name."正在".$this->school.
			"学习"."<br>";
					}
								}




class Teacher extends Student  {
	var $wage;
	function tech(){
			echo $this->name."正在".$this->school.
			"教学"."工资是".$this->wage."<br>";
					}		


								}	

$t1=new Teacher("魏莹悦","20","女");
$t1->school="Neusoft";
$t1->wage="6000";
$t1->say();
$t1->study();
$t1->tech();


 ?>



</body>
</html>


